package com.bw.zhuangao5___day002.Fragment.Books;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;

import com.blankj.utilcode.util.ToastUtils;
import com.bw.zhuangao5___day002.Apk.App;
import com.bw.zhuangao5___day002.R;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

/**
 * create by ertu
 * create on 2021/9/23
 * description
 */
public class StandardGSYVideoYANG  extends StandardGSYVideoPlayer {



    public Long asd=0L;

    public StandardGSYVideoYANG(Context context) {
        super(context);
    }

    public StandardGSYVideoYANG(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    @Override
    public int getLayoutId() {
        return R.layout.gsvyshipinlayout;
    }


    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction()==MotionEvent.ACTION_DOWN)
        {
            if (System.currentTimeMillis()-asd<=400)
            {
                ImageView imageView = new ImageView(App.context);
                imageView.setLayoutParams(new ViewGroup.LayoutParams(150,150));
                imageView.setImageResource(R.drawable.dong1);
                imageView.setX(event.getX());
                imageView.setY(event.getY());

                ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"alpha",1,0);
                objectAnimator.setDuration(2000);
                objectAnimator.start();
                addView(imageView);
                CheckBox viewById = findViewById(R.id.aixin);
                viewById.setChecked(true);
            }
        }else {
            asd=System.currentTimeMillis();
        }
        return super.onTouch(v, event);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return super.onTouchEvent(event);
    }

    @Override
    protected void touchDoubleUp(MotionEvent e) {
        //不使用
    }

    @Override
    protected void touchLongPress(MotionEvent e) {
        ToastUtils.showShort("先生！您今天很坏帅气。");
    }
}
